package metier;
import java.util.List;


import org.hibernate.Session;
import org.hibernate.Transaction;
import dao.ArticleDAO;
import dao.ClientDAO;
import dao.FournisseurDAO;
import dao.TaxeDAO;
import persistence.BaseDAO;


public class FournisseurManager {
	
	public static List getAllFournisseurs()	throws Exception {
		Session session = BaseDAO.getInstance().openSession();
		Transaction tx = null;
		try {
			tx = session.beginTransaction();
			List list  = FournisseurDAO.getListFournisseur("from Fournisseur",session);
			session.close();
			return list;
		} catch (Exception e) {
			if (tx != null) {
				tx.rollback();
			}
			e.printStackTrace();			
			throw new Exception(e.getMessage());
		}
	}

	public static List getFournisseurs(int start, int limit) throws Exception {
		Session session = BaseDAO.getInstance().openSession();
		Transaction tx = null;
		try {
			tx = session.beginTransaction();
			List list  = FournisseurDAO.getListFournisseur("from Fournisseur",session,start,limit);
			session.close();
			return list;
		} catch (Exception e) {
			if (tx != null) {
				tx.rollback();
			}
			e.printStackTrace();			
			throw new Exception(e.getMessage());
		}
	}
}
